<?php
require_once './dingtalk.php';
$dingtalk=new dingtalk();
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
     content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <style type="text/css">
    *{margin: 1%}
  </style>
  <title>钉钉扫码登录</title>
</head>
<?php
echo "<img src=".$dingtalk->getCode().">";
// echo '<br/>'.$dingtalk->CurlHeader('https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoamikxjdqgho42yt8y&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=https://oa.stgeek.cn/&loginTmpCode=54a7224da6363a34aafd48e782796d58');
?>
<script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
<script>
    $(function () {
        
        login();
    });
    function login(){
        var qrcode="<?php echo $dingtalk->qrCode;?>";
        var uim="<?php echo $dingtalk->uim;?>";
            $.ajax({
                type: "Post",
                url: "/getuser.php",
                data: {
                    qrcode:qrcode,uim:uim
                },
                dataType: "json",
                success: function (result) {
                    if (result.code == 1) {
                        alert(result.data);
                    }else{
                        login();
                    }
                }
            });
        }
</script>
</body>
</html>